import { Component, EventEmitter, Input, Output, OnInit, OnChanges } from '@angular/core';
import { Assembly, AssemblyStyles, AssemblyValidators, AssemblyConfigs } from '../../../fb-design.model'
import { SelectItem, DialogService } from 'primeng/primeng';
import { QkItemAttributes } from '../common/qk-item-attributes.component';

@Component({
    selector: 'qk-checkbox-attributes',
    templateUrl: 'qk-checkbox-attributes.component.html',
    styleUrls: ['qk-checkbox-attributes.component.scss'],
    providers: []
})
export class QkCheckboxAttributes implements OnInit {
    @Input() assembly: Assembly;
    @Input() 
    set names(names: string[]){
        let temp = [];
        names.forEach(e => temp.push({label: e, value: e}));
        this.nameItems = temp;
    }
    yesNo: SelectItem[] = [{ label: '否', value: false }, { label: '是', value: true }];
    angle: SelectItem[] = [{ label: '水平', value: 1 }, { label: '垂直', value: 2 }];
    nameItems: SelectItem[];
    ngOnInit() {
    }

    constructor(public dialogService: DialogService) { }

    editItems() {
        const ref = this.dialogService.open(QkItemAttributes, {
            header: '选项编辑',
            width: '450px',
            contentStyle: { 'height': '450px' },
            data: {
                items: this.assembly.configs.items
            }
        });
        ref.onClose.subscribe(data => {
            this.assembly.configs.items = JSON.stringify(data);
        });
    }

}